 {include file="public/header" /}
 {load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style type="text/css">
#des,#des input{ width: 40px;text-align:center;}
#id{ width: 78px; }
.bs-checkbox{ width: 36px; height: 40px }
.fixed-table-toolbar .columns,.fixed-table-toolbar .search{margin-left:0px; margin-top: 0px }
#title span{ float: right; margin-left: 3.333px;}
.search{ margin-bottom: 0px !important; }
.asdlkjasd{ background: #1ab394; color: #fff}

</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">

                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='0'}asdlkjasd{/eq}{/present}" href="{:url('labelcreate',['shenhe'=>0])}">审核</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('labelcreate',['shenhe'=>1])}">通过</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('labelcreate',['shenhe'=>-1])}">拒绝</a>
                    </div>
                    
                     
                    
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">父级</th>
                                    <th>用户</th>
                                    <th>名称</th>
                                    <th>创建原因</th>
                                    <th>创建时间</th>
                                    <th data-align="center">状态</th>
                                    <th>管理</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td id="id">{$v.id}</td>

                                    <td>{$v.parent.name}({$v.parent.id})</td>
                                    <td><?php
    $user=_user($v['user_id']);
    echo $user ? $user['name'] : '';
                                    ?>({$v.user_id})</td>
                                    
                                    <td id="title">
                                    {$v['title']}
                                    </td>
                                    <td>{$v.description}</td>
                                    <td> 
                                        <span {php}if(date('Ymd')==$v['create_time'])echo 'style="color: #ed5565"';{/php}>{:date('Y-m-d H:i', $v.create_time)}</span>
                                    </td>
                                    <td id="hide{$v.id}">{if condition="$v.state eq '0'"}<span style="color: #ed5565">审 核</span>{elseif condition="$v.state eq '1'" /}<span style="color: #1ab394">通 过</span>{elseif condition="$v.state eq '-1'" /}<span style="color: #ed5565">拒 绝</span>{/if}</td>
                           
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                {switch name="$v.state"}
                                                {case value="0"}
                                                <li><a onClick="shenhe({$v.id},'1')"><span style="color: #1ab394; ">通过</span></a></li>
                                                <li><a onClick="shenhe({$v.id},'-1')"><span style="color: #ed5565; ">拒绝</span></a></li>
                                                {/case}
                                                {/switch}
                                                <li class="divider"></li>
                                                <li><a onclick="del('{$v.id}')">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6">
                    <div  class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(-1)">
                        批量拒绝
                    </div>
                    <a href="?order=1" type="button" class="btn btn-outline btn-default">
                        倒序排序
                    </a>
                    <a href="?order=2" type="button" class="btn btn-outline btn-default">
                        顺序排序
                    </a>
                    <div  class="btn btn-outline btn-default" onclick="alla('del')">
                        批量删除
                    </div>
                </div>
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){
        $('#delidAll').click(function(){
            $('input[type=checkbox]').each(function(){
                var self=$(this);
                if(!self.prop('checked')){
                    self.prop('checked',true);
                }else{
                    self.prop('checked',false);
                }
            });
        })
});
function del(id){
    swal_del(id,"{:url('labelcreateDel')}")
}
function alla(types){
    var all=$(".form-horizontal").serialize();
    var alls=$(".form-horizontal").serializeArray();
    console.log(JSON.stringify(alls))

    ajaxFun("post",'{:url('templete/labelcreateshenheAll')}?type='+types,all,'json',function(ret){

        if(ret){
            var text
            switch(types)
            {
                case -1:
                    text = '<span class="btn btn-primary btn-xs" style="background-color: #414141;border-color:#414141">拒 绝</span>';
                    break;
                case 0:
                    text = '<span class="btn btn-default btn-xs">审 核</span>';
                    break;
                case 1:
                    text = '<span class="btn btn-primary btn-xs">通 过</span>';
                    break;
            }
            for(var i=0;i<alls.length;i++){
                if(types=='del'){
                    $('#id'+alls[i]['value']).remove();
                }else{
                    $('#hide'+alls[i]['value']).html(text);
                }
            }

            swal_msg('操作成功')
        }
    })

}
 
function shenhe(id,value){
    ajaxFun("post","{:url('labelcreateshenhe')}",{id:id,shenhe:value},'json',function(ret){
        if(ret){
            if(ret.ret){
                layer.msg(ret.ret)
                /*$("#id"+id).hide('fast',function(){
                     $("#id"+id).remove();
                })*/
                window.location.reload()
            }else{
                layer.msg(ret.err)
            }
        }else{
            swal_msg("错误",ret,"error");
        }
    })
}
</script>
 